package WaiBao;

import java.util.Arrays;

public class LiYuFang {
    public static void main(String[] args) {
        String[] name = {"王生安(班长)", "柴猫(副班长)", "小李(学习委员)", "潘恩已(组织委员)", "张顺股", "适当舒", "周卓豪", "辰过意", "文章想", "王诗雨", "张召重", "宁郁郁",
                "夏立克", "天刀山", "李大华", "文装箱", "王海", "宁固的", "张相德", "车红米", "张焕海", "旺仔源", "魏依然", "王吉吉", "李毛毛", "梅朝正", "吴川依", "胡惟庸",
                "欧豪辰", "李玉芳(学生)"};//考生本人:李玉芳(学生)
        int[] age = {18, 18, 22, 19, 20, 20, 21, 21, 19, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 21};//最后一位考生本人年龄：21


        double[] hya1 = {74, 78, 86,87, 82, 69, 78, 99, 60, 80, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 95};
        double[] hya2 = {65, 84, 77, 65, 98, 87, 88, 89, 60, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 95};
        double[] hya3 = {86, 89, 75, 64, 81, 75, 69, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 95};


        double freesia;//代表每个学生的总分
        double begonia;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            freesia = hya1[i] + hya2[i] +hya3[i];
//            begonia= (freesia * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + freesia);
//            System.out.println(name[i] + "的平均分为:" + begonia);
//        }



        double wis = 0, red = 0;
        double[] peony = new double[30];
//        for (int i = 0; i < 30; i++) {
//            wis = hya1[i] +hya2[i] + hya3[i];
//            red= ( wis * 1.0) / 3;
//            peony[i] = red;
//        }
//
//        for (int i = 0; i <  peony.length - 1; i++) {
//            for (int j = 0; j <  peony.length - i - 1; j++) {
//                if ( peony[j] <  peony[j + 1]) {
//                    double temp =  peony[j];
//                    peony[j] =  peony[j + 1];
//                    peony[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( peony[i]);
//        }





        double lilac1 = 0, lilac2 = 0,  lilac3 = 0;//计算每门课的平均分
        double pistl1 = 0, pistl2 = 0,  pistl3 = 0;//计算每门课标准差
        double ovary1 = 0, ovary2 = 0, ovary3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < hya1.length; i++) {
            sum2+=hya1[i];
        }
        lilac1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ lilac1);
        double Sum = 0;
        for (int i = 0; i < hya2.length; i++) {
            Sum+=hya2[i];
        }
        lilac2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+ lilac2);
        double sum = 0;
        for (int i = 0; i <hya3.length; i++) {
            sum+=hya3[i];
        }
        lilac3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+ lilac3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < hya1.length; i++) {
            c1+= (hya1[i] - lilac1)*(hya1[i] -  lilac1);
        }
        pistl1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ pistl1);

        for (int i = 0; i <hya2.length; i++) {
            c2+= (hya2[i] - lilac2)*(hya2[i] -  lilac2);
        }
        pistl2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ pistl2);

        for (int i = 0; i <hya3.length; i++) {
            c3+= (hya3[i] -  lilac3)*(hya3[i] -  lilac3);
        }
        pistl3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ pistl3);
//
//        Arrays.sort(hya1);
//        Arrays.sort(hya2);
//        Arrays.sort(hya3);
//        ovary1 =( hya1[14]+hya1[15])*1.0/2;
//        ovary2 =( hya2[14]+hya2[15])*1.0/2;
//        ovary3 =( hya3[14]+hya3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+ovary1);
//        System.out.println("线性代数的中位数为:"+ovary2);
//        System.out.println("有机化学学的中位数为:"+ovary3);
    }
}
